package com.zhiche.lisa.bms.enums;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * @author: linbao
 * @date: 2019-04-25
 */
public enum SdCommonEnum {
    NEW(0, "新增"),
    AUDIT(1, "已审核"),
    FAILE(2, "审核失败"),

    /**
     * 油价类型
     */
    OIL_TYPE_0(0, "0#柴油"),
    OIL_TYPE_92(1, "92#汽油"),

    /**
     * 优先级
     */
    LEVEL_0(0, "低"),
    LEVEL_1(1, "中"),
    LEVEL_2(2, "高"),

    /**
     * 油价联动
     */
    IS_LINK_NO(0, "否"),
    IS_LINK_YES(1, "是"),

    FLOAT_PRICE_TRADITION(0, "总运费"),
    FLOAT_PRICE_COST(1, "劳务费"),
    FLOAT_PRICE_OIL(2, "油费"),

    /**
     * 价格模式; 0-传统价格模式, 1-人送价格模式, 2-一口价模式
     */
    PRICE_MODEL_TRADITION(0, "传统价格模式"),
    PRICE_MODEL_DRIVER_SEND(1, "人送价格模式"),
    PRICE_MODEL_FIXED_PRICE(2, "一口价模式");

    public static final BigDecimal ZENE_AND_NOE = new BigDecimal(0.1).setScale(1, BigDecimal.ROUND_HALF_UP);

    private final Integer code;

    private final String value;

    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    SdCommonEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }


    /**
     * 获取优先级说明
     *
     * @param status
     * @return
     */
    public static String getStatusValue(Integer status) {
        if (Objects.nonNull(status)) {
            if (NEW.getCode().equals(status)) {
                return NEW.getValue();
            } else if (AUDIT.getCode().equals(status)) {
                return AUDIT.getValue();
            } else if (FAILE.getCode().equals(status)) {
                return FAILE.getValue();
            }
        }
        return null;
    }

    /**
     * 获取燃油类型说明
     *
     * @param oilType
     * @return
     */
    public static String getOilTypeValue(Integer oilType) {
        if (Objects.nonNull(oilType)) {
            if (OIL_TYPE_0.getCode().equals(oilType)) {
                return OIL_TYPE_0.getValue();
            } else if (OIL_TYPE_92.getCode().equals(oilType)) {
                return OIL_TYPE_92.getValue();
            }
        }
        return null;
    }

    /**
     * 获取油价联动说明
     *
     * @param linkFlag
     * @return
     */
    public static String getOilLinkFlagValue(Integer linkFlag) {
        if (Objects.nonNull(linkFlag)) {
            if (IS_LINK_YES.getCode().equals(linkFlag)) {
                return IS_LINK_YES.getValue();
            } else if (IS_LINK_NO.getCode().equals(linkFlag)) {
                return IS_LINK_NO.getValue();
            }
        }
        return null;
    }


    /**
     * 获取优先级说明
     *
     * @param level
     * @return
     */
    public static String getLevelValue(Integer level) {
        if (Objects.nonNull(level)) {
            if (LEVEL_0.getCode().equals(level)) {
                return LEVEL_0.getValue();
            } else if (LEVEL_1.getCode().equals(level)) {
                return LEVEL_1.getValue();
            } else if (LEVEL_2.getCode().equals(level)) {
                return LEVEL_2.getValue();
            }
        }
        return null;
    }

    /**
     * 获取价格模式说明
     *
     * @param priceModel
     * @return
     */
    public static String getPriceModelValue(Integer priceModel) {
        if (Objects.nonNull(priceModel)) {
            if (PRICE_MODEL_TRADITION.getCode().equals(priceModel)) {
                return PRICE_MODEL_TRADITION.getValue();
            } else if (PRICE_MODEL_DRIVER_SEND.getCode().equals(priceModel)) {
                return PRICE_MODEL_DRIVER_SEND.getValue();
            } else if (PRICE_MODEL_FIXED_PRICE.getCode().equals(priceModel)) {
                return PRICE_MODEL_FIXED_PRICE.getValue();
            }
        }
        return null;
    }
}
